package com.xuxin.baby.adapter;

import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.UserChildBean;
import com.xuxin.baby.glide.GlideApp;
import com.xuxin.baby.network.Retrofit;
import com.xuxin.baby.utils.BaseUtils;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.05 0005
 * 我的宝宝
 */
public class UserChildAdapter extends BaseQuickAdapter<UserChildBean.ResultBean.ItemsBean, BaseViewHolder> {
    RequestOptions options = RequestOptions.bitmapTransform(new CircleCrop());

    public UserChildAdapter() {
        super(R.layout.item_user_child);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, UserChildBean.ResultBean.ItemsBean item) {
        holder.setText(R.id.item_user_child_name, item.getNickname());
        holder.setText(R.id.item_user_child_birthday, BaseUtils.getTime(item.getBirthday()));
        /**
         * 加载图片
         */
        ImageView item_user_child_image = holder.getView(R.id.item_user_child_image);
        String childImage = Retrofit.image_url + item.getAvatar();
        LogUtils.e("我的宝宝_image = " + childImage);
        GlideApp.with(getContext()).load(childImage).placeholder(R.mipmap.img_placeholder_head).apply(options).into(item_user_child_image);
    }
}